package com.reverse.engineering.util.core.run.util;

import java.io.IOException;
import java.util.Map.Entry;

import com.reverse.engineering.util.core.run.bean.TemplateMessage;
import com.reverse.engineering.util.core.run.bean.Templates;

import java.util.Set;

/**
 * 读取模板类
 * 
 * @author liu
 * @date 2020-08-20
 */
public class ReadTemplate {

    /**
     * 读取模板文件
     * 
     * @throws IOException
     */
    public static void readTemplate() throws IOException {
        FileUtils.initTemplatePathsByBasePath();
        Set<Entry<String, TemplateMessage>> templateEntrySet = Templates.template.entrySet();
        for (Entry<String, TemplateMessage> entry : templateEntrySet) {
            TemplateMessage templateMessage = entry.getValue();
            templateMessage.setPlaceholder("~" + entry.getKey() + "~");
            templateMessage.setContent(FileUtils.getContentByPath(templateMessage.getPath()));
        }
    }

}